﻿@namespace MudBlazor.Docs.Examples

<InputFile id="fileInput" OnChange="UploadFiles" hidden multiple />

<MudButton HtmlTag="label"
           Variant="Variant.Filled"
           Color="Color.Primary"
           StartIcon="@Icons.Filled.CloudUpload"
           for="fileInput">
    Upload Files
</MudButton>

<MudFab HtmlTag="label"
        Color="Color.Secondary"
        Icon="@Icons.Filled.Image"
        Label="Load picture"
        for="fileInput" />

<MudFab HtmlTag="label"
        Color="Color.Success"
        Icon="@Icons.Filled.AttachFile"
        for="fileInput" />

<MudIconButton HtmlTag="label"
               Color="Color.Info"
               Icon="@Icons.Filled.PhotoCamera"
               for="fileInput">
</MudIconButton>

@if (files != null)
{
    <MudText Typo="@Typo.h6">@files.Count() File@(files.Count() == 1 ? "" : "s"):</MudText>
    <MudList>
    @foreach (var file in files)
    {
     <MudListItem Icon="@Icons.Filled.AttachFile" @key="@file">
         @file.Name <code>@file.Size bytes</code>
     </MudListItem>
    }
    </MudList>
}

@code
{
    IList<IBrowserFile> files = new List<IBrowserFile>();
    private void UploadFiles(InputFileChangeEventArgs e)
    {
        foreach (var file in e.GetMultipleFiles())
        {
            files.Add(file);
        }
        //TODO upload the files to the server
    }
}